package cn.hhy.org.service.impl;

import cn.hhy.org.domain.Employee;
import cn.hhy.org.domain.Employee;
import cn.hhy.org.mapper.EmployeeMapper;
import cn.hhy.org.query.EmployeeQuery;
import cn.hhy.org.service.IEmployeeService;
import cn.hhy.utils.QueryResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public void PatchDelete(Long[] ids) {
        employeeMapper.PatchDelete(ids);
    }

    @Override
    public void save(Employee employee) {
        employeeMapper.save(employee);
    }

    @Override
    public void update(Employee employee) {
        employeeMapper.update(employee);
    }

    @Override
    public void delete(Long id) {
        employeeMapper.delete(id);
    }

    @Override
    public Employee loadById(Long id) {
        return employeeMapper.loadById(id);
    }

    @Override
    public List<Employee> loadAll() {
        return employeeMapper.loadAll();
    }

    @Override
    public QueryResult<Employee> employeeLoadAll(EmployeeQuery employeeQuery) {
        Long employeeCountByQuery = employeeMapper.findEmployeeCountByQuery(employeeQuery);
        List<Employee> employeeByQuery = employeeMapper.employeeLoadAll(employeeQuery);
        return new QueryResult<Employee>(employeeCountByQuery,employeeByQuery);
    }


}
